<template>
    <div class="handle-comprehensive-box"  :key="materialReviewExaminationKey">
        <div class="process-handling-card" v-if="!currentRow.isTopTabs">
            <a-tabs type="card" v-model:activeKey="activeKey" @change="tabPaneChange">
                <a-tab-pane v-if="currentRow.fclscms !== '2'" key="技术审评材料汇总" tab="技术审评材料汇总"></a-tab-pane>
                <!-- <a-tab-pane key="企业整改材料" tab="企业整改材料"></a-tab-pane> -->
                <a-tab-pane v-if="currentRow.fhjmc !== '综合评定复核'" key="综合评定" tab="综合评定"></a-tab-pane>
                <!-- <a-tab-pane key="报告制作" tab="综合评定报告书"></a-tab-pane> -->
                <!-- <a-tab-pane key="移送函报告" tab="移送函"></a-tab-pane> -->
                
                <!-- boxHeight -->
                <!-- <a-tab-pane key="申请信息" tab="事项信息"></a-tab-pane> -->
                <a-tab-pane key="环节流转记录" tab="流转记录"></a-tab-pane>
            </a-tabs>
        </div>
        <div class="comprehensive-review-content" :style="{height: currentRow.isScyjBox?'calc(100vh - 121px)':(currentRow.isTopTabs?'calc(100vh - '+140+'px)':'calc(100vh - '+152+'px)'),borderTop:!currentRow.isTopTabs?'none' :'1px solid #38f'}">
            <div v-show="activeKey == '综合评定'">
                <div style="display: flex;justify-content: space-between;align-items: center;" >
                    <div class="business-number">
                        <!-- <div class="business-number-dg">
                            <span class="business-name-text">业务分类：</span>
                            <span style="width: 139px;">{{ currentRow.fjclx }}</span>
                        </div> -->
                        <div class="business-number-dg">
                            <span class="business-name-text">评定编号：</span>
                            <a-input style="margin: 0 10px 0 3px;width: 230px;" @blur="saveData('fpdbh',currentRow.fpdbh)" placeholder="请输入评定编号" v-model:value="currentRow.fpdbh"/>
                            <a-button size="small" class="blue-btn" type="primary" @click="numbering('评定编号')" icon="file-done">取号</a-button>
                        </div>
                        <div class="business-number-dg">
                            <span class="business-name-text">综合评定结论：</span>
                            <compSelector
                                :key="fzhjgKey"
                                v-model="currentRow.fzhjg"
                                compType="Select"
                                :defaultValue="currentRow.fzhjg"
                                dictionaryType="检查结果"
                                @selectHandleChange="saveData('fzhjg',currentRow.fzhjg)"
                            />
                            <!-- <a-button style="margin-left: 20px;" size="small" class="blue-btn" type="primary" @click="numbering('生成报告内容')" icon="check-circle">生成报告内容</a-button> -->
                        </div>
                    </div>
                    <!-- <a-button id="fxqxqk-scbg-btn" class="green-l2-btn" type="primary" @click="generateReportChange('完成')" icon="check-circle">生成综合评定报告书</a-button> -->
                </div>
                <div>
                    <!-- <div style="display: flex;align-items: center;">
                        <span class="business-name-text">综合评定结论：</span>
                        <compSelector
                            :key="fzhjgKey"
                            v-model="currentRow.fzhjg"
                            compType="Select"
                            :defaultValue="currentRow.fzhjg"
                            dictionaryType="审评结果"
                            @selectHandleChange="saveData('fzhjg',currentRow.fzhjg)"
                        />
                        <a-button style="margin-left: 20px;" size="small" class="blue-btn" type="primary" @click="numbering('生成报告内容')" icon="check-circle">生成报告内容</a-button>
                    </div> -->
                    <div>
                        <a-textarea 
                            @blur="saveData('fzhjl',currentRow.fzhjl)"
                            placeholder="请输入报告内容"
                            v-model:value="currentRow.fzhjl"
                            :autosize="{ minRows: 2, maxRows: 2 }"
                        ></a-textarea>
                    </div>
                    <div style="margin: 10px 0;">
                        <span>其他问题：</span>
                    </div>
                    <div>
                        <a-textarea 
                            @blur="saveData('fzhbgqtwt',currentRow.fzhbgqtwt)"
                            placeholder="请输入其他问题"
                            v-model:value="currentRow.fzhbgqtwt"
                            :autosize="{ minRows: 2, maxRows: 2 }"
                        ></a-textarea>
                    </div>
                </div>
                <!-- <div style="display: flex;justify-content: flex-end;margin: 10px 0;">
                    <a-button class="blue-btn" type="primary" @click="activeKey = '报告制作'" icon="arrow-right">下一步</a-button>
                </div> -->
                <div style="display: flex;margin-top: 5px;" >
                    <div style="width: 30%;">
                        <table border bordercolor="#d9d9d9" style="width: 100%; " >
                            <tr v-for="(item,index) in JSSCBGList" :key="index" class="file-list-v-examination">
                                <td :colspan="2">
                                    <div style="display: flex;justify-content: space-between;" >
                                        <a-tooltip placement="topRight">
                                            <template slot="title">
                                                <span>{{ item.clmc }}</span>
                                            </template>
                                            <span class="directory-list-fmlmc" style="font-weight: 600;" >{{ item.clmc }}</span>
                                        </a-tooltip>
                                        <a-upload :beforeUpload="$event=>{return false}" :showUploadList="false" action="" @change="$event=>{singleZHPDUploadCahnge($event,item.clmc)}">
                                            <!-- && item.name !== '审评方案' -->
                                            <a-button
                                            size="small"
                                            class="ant-btn-green-l-ghost" 
                                            type="primary" ghost >上传</a-button>
                                        </a-upload>
                                    </div>
                                    
                                    <div class="file-for-box">
                                        <div class="file-for-v-1" v-for="(trem,tIndex) in item.wjList" :key="tIndex"
                                            :class="iframeData.id == trem.id?'select-file-list-examination':''" 
                                            @click="selectJSSCBG(trem)"
                                            >
                                            <a  class="name-fclmc-text">{{ trem.fwjxsmc+trem.fwjlx }}</a>
                                            <a-icon type="download" style="display: inline-block;font-size:16px;margin: 0 10px;color: #38f;" @click.top.prevent="downloadFiles(trem)"/>
                                            <a-icon style="display: inline-block;font-size:16px;color: #ed5565;" @click="deleteCheckDirectories(trem)" type="delete" />
                                            <!-- @click="downloadClick(trem)" -->
                                            <!-- <a-icon style="padding: 0 3px;" class="eye-icon-v" type="eye" @click="fetchAndAddWatermark(trem)" v-if="trem.fclmc.indexOf('.pdf') !== -1"/> -->
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div style="flex: 1;margin-left: 5px;" >
                        <a-spin tip="正在加载中..." :spinning="iframeSpinning">
                            <div  >
                                <div v-if="iframeData.fclmc">
                                    <span style="font-size: 16px;border: 2px solid #ff9200;color: #ff9200;padding: 0 3px;display: inline-block;border-radius: 15px;margin-left: 5px;margin-bottom: 5px;">{{ iframeData.fclmc }}</span>
                                </div>
                                <iframe :src="zhpdiframeSrc" width="100%" :height="windowInnerHeight - 390+'px'"  v-if="zhpdiframeSrc"></iframe>
                                <div v-else>
                                    <a-empty description="暂无文件或文件发生错误！"/>
                                </div>
                            </div>
                        </a-spin>
                    </div>
                </div>
               
                
            </div>
            <div v-if="false">
                <a-spin size="large" :spinning="programSpinning" :key="programSpinningKey" tip="正在加载中...">
                    <div v-if="programData.id" :key="programSpinningKey">
                        <div style="display: flex;justify-content: space-between;" >
                            <div>
                                <a-button
                                        style="margin-right: 15px;" 
                                        class="red-btn" type="primary" 
                                        @click="producerDelete(programData,'综合评定')" icon="delete">删除</a-button>
                                <!-- <a-button
                                style="margin-right: 15px;" 
                                class="blue-btn" type="primary" 
                                @click="refreshFile" icon="reload">刷新</a-button>

                                <a-button
                                style="margin-right: 15px;" 
                                class="blue-btn" type="primary" 
                                @click="downloadFiles(programData)" icon="download">下载</a-button>

                                <a-button
                                v-if="programData.fwjlx == '.pdf'"
                                style="margin-right: 15px;" 
                                class="blue-btn" type="primary" 
                                @click="reEdit" icon="form">重新编辑</a-button>

                                <a-button
                                v-if="programData.fwjlx !== '.pdf'"
                                style="margin-right: 15px;" 
                                class="blue-btn" type="primary" 
                                @click="saveFiles" icon="folder">保存</a-button>

                                <a-button
                                v-if="programData.fwjlx !== '.pdf'"
                                style="margin-right: 15px;" 
                                class="blue-btn" type="primary" 
                                @click="generatePDFClick" icon="file-pdf">生成PDF</a-button>

                                <a-button
                                v-if="programData.fwjlx == '.pdf'"
                                style="margin-right: 15px;" 
                                class="blue-btn" type="primary" 
                                @click="stampClick" icon="audit">盖章</a-button>

                                <a-button
                                v-if="programData.fwjlx !== '.pdf'"
                                style="margin-right: 15px;"
                                class="blue-btn" type="primary" 
                                @click="generatePDFStampClick" icon="audit">生成PDF并盖章</a-button>

                                <a-button 
                                v-if="programData.fwjlx !== '.pdf'"
                                class="blue-btn" type="primary" 
                                @click="reSelectTemplate" icon="select">重新选择模板</a-button> -->
                            </div>
                            <a-button class="orange-btn" type="primary" id="fxqxqk-cxbjqxx-btn" @click="generateReportChange('重新编辑')" icon="form">重新编辑缺陷项</a-button>
                        </div>
                        
                        <div :key="iframeKey" style="display: flex;justify-content: center;">
                            <iframe 
                                v-if="iframeSrc"
                                :key="iframeKey"
                                :src="iframeSrc" 
                                ref="iframeServerEditingRef" 
                                scrolling="auto" 
                                width="100%"
                                :height="(windowInnerHeight -170 )+'px'"
                                style="border: 0;"
                            ></iframe>
                            <span v-else>当前文件发生错误，请刷新！</span>
                        </div>
                        <!-- {{ programData }} -->
                    </div>
                    <div v-else>
                        <div style="display: flex;justify-content: space-between;margin: 0 15px;" >
                            <!-- <span style="color: red;font-weight: 600;">(注：当前暂无报告制作文件，请先选择模板进行报告制作)</span> -->
                            <a-upload style="display: inline-block;" :beforeUpload="$event=>{return false}" :showUploadList="false" action="" @change="singleUploadCahnge($event,'综合评定报告书')">
                                <a-button
                                class="blue-btn" 
                                style="width: 124px;"
                                type="primary" icon="upload">上传</a-button>
                            </a-upload>
                            <a-button class="orange-btn" type="primary" id="fxqxqk-cxbjqxx-btn" @click="generateReportChange('重新编辑')" icon="form">重新编辑综合评定报告书</a-button>
                        </div>
                        <!-- <selectTemplateNoModel
                        :key="programTemplateKey"
                         ref="selectTemplateNoModel1Ref" 
                         @selectTemplateComplete="selectTemplateComplete" 
                         @programSpinningChange="programSpinningChange" /> -->
                    </div>
                </a-spin>
            </div>
            <div v-show="activeKey == '移送函报告'">
                <div style="display: flex;justify-content: space-between;margin-right: 15px;align-items: flex-end;">
                    <div class="business-number">
                        <div class="business-number-dg">
                            <span class="business-name-text" style="width: 84px;" >移送编号：</span>
                            <a-input style="margin: 0 10px 0 3px;width: 230px;" @blur="saveData('fyshbh',currentRow.fyshbh)" placeholder="请输入移送编号" v-model:value="currentRow.fyshbh"/>
                            <a-button size="small" class="blue-btn" type="primary" @click="numbering('移送编号')" icon="file-done">取号</a-button>
                        </div>
                    </div>
                    <!-- <span v-if="!transferLetterData.id" style="color: red;font-weight: 600;">(注：当前暂无移送函报告文件，请先选择模板进行移送函报告)</span> -->
                </div>
                
                <a-spin size="large" :spinning="programSpinning" :key="programSpinningKey" tip="正在加载中...">
                    <div v-if="transferLetterData.id" :key="programSpinningKey" style="margin: 0 15px;">
                        
                        <div>
                            <a-button
                                style="margin-right: 15px;" 
                                class="red-btn" type="primary" 
                                @click="producerDelete(transferLetterData,'移送函报告')" icon="delete">删除</a-button>
                            <!-- <a-button
                            style="margin-right: 15px;" 
                            class="blue-btn" type="primary" 
                            @click="refreshFile" icon="reload">刷新</a-button>

                            <a-button
                            style="margin-right: 15px;" 
                            class="blue-btn" type="primary" 
                            @click="downloadFiles(transferLetterData)" icon="download">下载</a-button>

                            <a-button
                            v-if="transferLetterData.fwjlx == '.pdf'"
                            style="margin-right: 15px;" 
                            class="blue-btn" type="primary" 
                            @click="reEdit" icon="form">重新编辑</a-button>

                            <a-button
                            v-if="transferLetterData.fwjlx !== '.pdf'"
                            style="margin-right: 15px;" 
                            class="blue-btn" type="primary" 
                            @click="saveFiles" icon="folder">保存</a-button>

                            <a-button
                            v-if="transferLetterData.fwjlx !== '.pdf'"
                            style="margin-right: 15px;" 
                            class="blue-btn" type="primary" 
                            @click="generatePDFClick" icon="file-pdf">生成PDF</a-button>

                            <a-button
                            v-if="transferLetterData.fwjlx == '.pdf'"
                            style="margin-right: 15px;" 
                            class="blue-btn" type="primary" 
                            @click="stampClick" icon="audit">盖章</a-button>

                            <a-button
                            v-if="transferLetterData.fwjlx !== '.pdf'"
                            style="margin-right: 15px;"
                            class="blue-btn" type="primary" 
                            @click="generatePDFStampClick" icon="audit">生成PDF并盖章</a-button>

                            <a-button 
                            v-if="transferLetterData.fwjlx !== '.pdf'"
                            class="blue-btn" type="primary" 
                            @click="reSelectTemplate" icon="select">重新选择模板</a-button> -->
                        </div>
                        <div :key="iframeKey" style="display: flex;justify-content: center;">
                            <iframe 
                                v-if="transferLetterIframeSrc"
                                :key="iframeKey"
                                :src="transferLetterIframeSrc" 
                                ref="iframeServerEditingRef" 
                                scrolling="auto" 
                                width="100%"
                                :height="(windowInnerHeight -170 )+'px'"
                                style="border: 0;"
                            ></iframe>
                            <div v-else>
                                <a-empty description="暂无文件或文件发生错误！"/>
                            </div>
                        </div>
                        <!-- {{ programData }} -->
                    </div>
                    <div v-else>
                        <a-upload style="display: inline-block;" :beforeUpload="$event=>{return false}" :showUploadList="false" action="" @change="singleUploadCahnge($event,'移送函')">
                            <a-button
                            class="blue-btn" 
                            style="width: 124px;"
                            type="primary" icon="upload">上传</a-button>
                        </a-upload>
                        <!-- <selectTemplateNoModel
                        :key="programSpinningKey"
                         ref="selectTemplateNoModel2Ref" 
                         @selectTemplateComplete="selectTemplateComplete" 
                         @programSpinningChange="programSpinningChange" /> -->
                    </div>
                </a-spin>
            </div>
            <div v-show="activeKey == '技术审评材料汇总'">
                <materialReviewExamination ref="materialReviewExaminationRef" :key="assignPersonnelKey"/>
                <!-- <assignPersonnel ref="assignPersonnelRef" :key="assignPersonnelKey"/> -->
            </div>
            <div v-if="activeKey == '企业整改材料'">
                <materialRectification
                v-if="currentRow.fclscms !== '2'"
                 @rectificationClick="rectificationClick" 
                 @historyListClick="historyListClick" 
                 ref="materialRectificationRef" 
                 :key="materialRectificationKey"
                 @renewDataChange="renewDataChange"
                />
                <revisionRectification v-if="currentRow.fclscms == '2'" ref="revisionRectificationRef" :key="materialRectificationKey"/>
            </div>
            <div v-if="activeKey == '申请信息'  || activeKey == '环节流转记录'" style="height: 100%;overflow: hidden;">
                <a-spin size="large" :spinning="modalSpinningPrice" tip="正在加载中...">
                    <eventSet
                        :key="eventSetKey" 
                        ref="examinationEventSetRef" 
                        @updatedSuccess="eventupdatedSuccess"
                    />
                </a-spin>
            </div>
            <selectTemplate ref="selectTemplateRef" @selectTemplateComplete="selectTemplateComplete"/>
            <serverEditingView ref="serverEditingViewRef" @refreshChange="$event=>{}"/>
            <serverEditing ref="serverEditingRef" @refreshChange="refreshChange"/>
        </div>
    </div>
</template>
<script>
import { 
    spcysaveFlow,
    spcyRsBhgzautoPdbhBySqsxId,
    spcyRsBhgzautoYshbhBySqsxId,
    spcygenerateZhpdConclusion,
    initWjgetZhpdBgsDjwc,
    initWjgetZhpdBgsCxbj,
    spcygetZhpdbgFile,
    spcygetZhpdYshFile,

    getWebOfficeDownloadFile,
    webOfficeApiopenFile,
    openFileReadOnly,
    getDocxToPdf,
    againEditPdfOnlineFile,
    getDocxToPdfAndGz,
    pdfFileHcCa,
    initWjgetZhpdBgsState,
    spcySqsxWjjldeleteFileById,
    spcyuploadSqsxFile,
    spcyzgpdbgml,
    spcySqsxWjjlgetLocalFileById,
    // initWjgetZhpdScyjState,
 } from './service/index'
 import YchConstant from "@/api/YchConstant";
 import blobType from '@/common/blobType'
 import eventSet from '../taskAcceptance/eventSet.vue'
import CommpStep from '../../../../../components/commp-step/commpStep.vue';
import assignPersonnel from '../onSiteInspection/sceneInspect.vue'
import compSelector from '@/components/compSelector/compSelector.vue'
import selectTemplateNoModel from '@/components/selectTemplate/selectTemplate-noModel.vue'
import selectTemplate from '@/components/selectTemplate/selectTemplate.vue'
import serverEditing from '@/components/comp-model-series/server-editing.vue'
import serverEditingView from '@/components/comp-model-series/server-editing-view'
import materialRectification from '../materialReview/enterpriseRectification.vue'
import revisionRectification from '../materialReview/revisionRectification.vue'
import materialReviewExamination from '../materialReview/examination.vue'
export default {
    components:{
        eventSet,
        CommpStep,
        assignPersonnel,
        compSelector,
        selectTemplateNoModel,
        selectTemplate,
        serverEditing,
        serverEditingView,
        materialRectification,
        revisionRectification,
        materialReviewExamination,
    },
    props:{

    },
    data(){
        return{
            activeKey:'',
            currentRow:{},
            materialReviewExaminationKey:null,
            eventSetKey:null,
            assignPersonnelKey:null,
            fzhjgKey:null,

            programSpinning:false,
            programSpinningKey:null,
            programTemplateKey:null,
            programData:{},
            iframeSrc:'',
            iframeKey:null,

            transferLetterData:{},
            transferLetterIframeSrc:'',
            modalSpinningPrice:true,
            windowInnerHeight:window.innerHeight,
            materialRectificationKey:null,
            comprehensiveReportState:false,
            reviewCommentsState:false,
            JSSCBGList:[],
            iframeData:{},
            zhpdiframeSrc:'',
            iframeSpinning:false,
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        async getData(row){
            //console.log('综合评定',row)
            this.currentRow = row
            this.spinning = true
            if(!row.noFirstLoad){
                this.activeKey = row.isActiveKey?row.isActiveKey:(this.currentRow.fclscms !== '2'?'技术审评材料汇总':'企业整改材料')
                this.materialReviewExaminationKey = Date.now()
                this.assignPersonnelKey = Date.now()
            }
            this.fzhjgKey = Date.now()
            if(this.currentRow.fclscms !== '2' || this.activeKey == '技术审评材料汇总'){
                this.$nextTick(()=>{
                    this.$refs.materialReviewExaminationRef.getData({sqsxid:this.currentRow.sqsxid,isTopTabs:true,isActiveKey:'材料审查',reserveBottom:64,isRefresh:false,fhjmc:this.currentRow.fhjmc,isDisabled:true})
                })
            }
            // 
            if(this.activeKey == '企业整改材料'){
                this.tabPaneChange('企业整改材料')
            }else if(this.activeKey == '综合评定' && this.comprehensiveReportState){
                this.getReportData()
                this.getZHPDBGData()
            }else if(this.activeKey == '移送函报告'){
                this.getTransferLetter()
            }
            await this.getStateData()
            
        },
        getZHPDBGData(){
            this.iframeSpinning = true
            spcyzgpdbgml({sqsxid:this.currentRow.sqsxid}).then(res=>{
                if(res.code == 200){
                    this.JSSCBGList = res.result
                    if(this.JSSCBGList.length && this.JSSCBGList[0].wjList.length){
                        this.selectJSSCBG(this.JSSCBGList[0].wjList[0])
                    }
                }else{
                    this.JSSCBGList = []
                }
                this.iframeSpinning = false
            })
        },
        async deleteCheckDirectories(row){
            var that = this
            this.$confirm({
                title:'您确认要删除吗？',
                // icon: createVNode(ExclamationCircleOutlined),
                content:'',
                async onOk() {
                    let res = await spcySqsxWjjldeleteFileById({id:row.id})
                        if(res.code == 200){
                            await that.getZHPDBGData()
                            that.iframeData = {}
                            if(row.id == that.iframeData.id){
                                that.zhpdiframeSrc = ''
                                if(that.JSSCBGList.length && that.JSSCBGList[0].wjList && that.JSSCBGList[0].wjList.length){
                                    that.selectJSSCBG(that.JSSCBGList[0].wjList[0])
                                    that.iframeData = that.JSSCBGList[0].wjList[0]
                                }
                            }
                        }else{
                            that.$message.warning(res.message)
                        }
                },
                
            });
        },
        selectJSSCBG(trem){
            this.zhpdiframeSrc = bootConfig[process.env.NODE_ENV].locality_ApI+YchConstant.SPZX_SPCY+'/spcySqsxWjjl/getCrossLocalFile?id='+trem.id
            this.iframeData = trem
        },
        singleZHPDUploadCahnge({file},val){
            var that = this
            const fileData = new FormData();
            fileData.append("file",file);
            fileData.append("sqsxid",this.currentRow.sqsxid);
            fileData.append("type",val);
            if(file.name.indexOf('.pdf') !== -1){
                spcyuploadSqsxFile(fileData).then(res => {
                    if(res.code !== 200){
                        that.$message.warning('请上传pdf文件或者联系管理员!')
                    }else{
                        that.getZHPDBGData()
                        that.$message.success('上传成功')
                    }
                    
                })
            }else{
                this.$message.warning('请上传pdf文件')
            }
            
        },
        getAssignPersonnelChange(){
            this.assignPersonnelKey = Date.now()
            this.$nextTick(()=>{
                this.$refs.materialReviewExaminationRef.getData({sqsxid:this.currentRow.sqsxid,isTopTabs:true,isActiveKey:'材料审查',reserveBottom:64,isRefresh:false,fhjmc:this.currentRow.fhjmc,isDisabled:true})
            })
        },
        successViewFinalFile(){
            this.tabPaneChange('企业整改材料')
        },
        getStateData(){
            initWjgetZhpdBgsState({sqsxid:this.currentRow.sqsxid}).then(res=>{
                if(res.code == 200){
                    this.comprehensiveReportState = res.result
                }else{
                    this.comprehensiveReportState = false
                }
            })
            // initWjgetZhpdScyjState({sqsxid:this.currentRow.sqsxid}).then(res=>{
            //     if(res.code == 200){
            //         this.reviewCommentsState = res.result
            //     }else{
            //         this.reviewCommentsState = false
            //     }
            // })
        },
        eventupdatedSuccess(){
            this.modalSpinningPrice = false
        },
        tabPaneChange(val){
            if(val == '综合评定'){
                this.getReportData()
                this.getZHPDBGData()
            }else if(val == '移送函报告'){
                this.getTransferLetter()
            }
            if(val == '申请信息'  || val == '环节流转记录'){
                // this.eventSetKey = Date.now()
                this.$nextTick(()=>{
                    this.$refs.examinationEventSetRef.getDatas({...this.currentRow,tabPaneActiveKey:val,noFirstLoad:true,borderisFalse:true})
                    this.modalSpinningPrice = true
                })
                
                // this.$refs.examinationEventSetRef.$refs.dealWithRef.tabPaneChange(val)
            }
            if(val == '企业整改材料'){
                if(this.currentRow.fclscms == '2'){
                    this.$nextTick(()=>{
                        setTimeout(()=>{
                            this.$refs.revisionRectificationRef.getData({
                                sqsxid:this.currentRow.sqsxid,
                                isTopTabs:true,
                                isActiveKey:'材料审查',
                                reserveBottom:-22,
                                heightNum:178,
                                isRefresh:false,
                                fhjmc:this.currentRow.fhjmc
                            })
                        })
                        
                    })
                }else{
                    this.$nextTick(()=>{
                        setTimeout(()=>{
                            this.$refs.materialRectificationRef.getData({
                                sqsxid:this.currentRow.sqsxid,
                                jobid:this.currentRow.jobid,
                                isTopTabs:true,
                                isActiveKey:'材料审查',
                                reserveBottom:228,
                                rightPreviewBoxH:this.currentRow.rightPreviewBoxH?this.currentRow.rightPreviewBoxH:window.innerHeight - 410,
                                heightNum:176,
                                isRefresh:false,
                                fhjmc:this.currentRow.fhjmc,
                                isDelete:true,
                                fzhpdyj:this.currentRow.fzhpdyj,
                                isScyjBox:this.currentRow.isScyjBox,
                                fsxmc:this.currentRow.fsxmc,
                                fqymc:this.currentRow.fqymc,
                            })
                        },200)
                    })
                }
            }
        },
        //取号
        numbering(name){
            if(name == '评定编号'){
                spcyRsBhgzautoPdbhBySqsxId({sqsxid:this.currentRow.sqsxid}).then(res=>{
                    if(res.code == 200){
                        this.currentRow.fpdbh = res.result.fpdbh
                        // this.$message.success(res.message)
                        this.saveData('fpdbh',this.currentRow.fpdbh)
                    }else{
                        this.$message.warning(res.message)
                    }
                })
            }else if(name == '移送编号'){
                spcyRsBhgzautoYshbhBySqsxId({sqsxid:this.currentRow.sqsxid}).then(res=>{
                    if(res.code == 200){
                        this.currentRow.fyshbh = res.result.fyshbh
                        // this.$message.success(res.message)
                        this.saveData('fyshbh',this.currentRow.fyshbh)
                    }else{
                        this.$message.warning(res.message)
                    }
                })
            }else if(name == '生成报告内容'){
                if(this.currentRow.fzhjg){
                    spcygenerateZhpdConclusion({sqsxid:this.currentRow.sqsxid}).then(res=>{
                        if(res.code == 200){
                            this.currentRow.fzhjl = res.result.fzhjl
                            // this.$message.success(res.message)
                            this.saveData('fzhjl',this.currentRow.fzhjl)
                        }else{
                            this.$message.warning(res.message)
                        }
                    })
                }else{
                    this.$message.warning('请先选择综合评定结论')
                }
                
            }
        },
        // 生成综合评定报告书
        generateReportChange(val){
            if(val == '完成'){
                initWjgetZhpdBgsDjwc({sqsxid:this.currentRow.sqsxid}).then(res=>{
                    if(res.code == 200){
                        this.$message.success(res.message)
                        this.comprehensiveReportState = true
                        this.getReportData()
                        // this.$nextTick(()=>{
                        //     this.$refs.selectTemplateNoModel1Ref.getSelectTemplate({},'综合评定报告书',this.currentRow.sqsxid)
                        //     this.$refs.selectTemplateNoModel1Ref.selectTemplateVisible = true
                        // })
                    }else{
                        this.$message.warning(res.message)
                    }
                })
            }else{
                initWjgetZhpdBgsCxbj({sqsxid:this.currentRow.sqsxid}).then(res=>{
                    if(res.code == 200){
                        this.$message.success(res.message)
                        this.comprehensiveReportState = false
                    }else{
                        this.$message.warning(res.message)
                    }
                })
            }
        },
        //报告制作
         getReportData(){
            spcygetZhpdbgFile({sqsxid:this.currentRow.sqsxid}).then(res=>{
                if(res.code == 200){
                    this.programData = res.result.length?res.result[0]:{}
                    if(res.result.length){
                        if(this.programData.fwjlx == '.pdf'){
                            this.iframeSrc = bootConfig[process.env.NODE_ENV].locality_ApI + YchConstant.SPZX_SPCY + '/spcyRsWjmb/openWjjl?id='+this.programData.id
                            this.iframeKey = Date.now()
                        }else{
                            this.openFileClick(this.programData)
                        }
                        
                    }else{
                        this.$nextTick(()=>{
                            this.$refs.selectTemplateNoModel1Ref.getSelectTemplate({},'综合评定报告书',this.currentRow.sqsxid)
                            this.$refs.selectTemplateNoModel1Ref.selectTemplateVisible = true
                        })
                        //console.log('我校在这里')
                    }
                    this.programSpinningKey = Date.now()
                    this.programTemplateKey = Date.now()
                }
                this.programSpinning = false
            })
         },
         //移送函
         getTransferLetter(){
            spcygetZhpdYshFile({sqsxid:this.currentRow.sqsxid}).then(res=>{
                if(res.code == 200){
                    this.transferLetterData = res.result.length?res.result[0]:{}
                    if(res.result.length){
                        if(this.transferLetterData.fwjlx !== '.doc' && this.transferLetterData.fwjlx !== '.docx'){
                            this.transferLetterIframeSrc = bootConfig[process.env.NODE_ENV].locality_ApI + YchConstant.SPZX_SPCY + '/spcyRsWjmb/openWjjl?id='+this.transferLetterData.id
                            this.iframeKey = Date.now()
                        }else{
                            this.openFileClick(this.transferLetterData)
                        }
                        
                    }else{
                        this.$nextTick(()=>{
                            this.$refs.selectTemplateNoModel2Ref.getSelectTemplate({},'移送函',this.currentRow.sqsxid)
                            this.$refs.selectTemplateNoModel2Ref.selectTemplateVisible = true
                        })
                    }
                    this.programSpinningKey = Date.now()
                }
                this.programSpinning = false
            })
         },
         openFileClick(val){//打开文件
            webOfficeApiopenFile({id:val.id}).then(res=>{
                if(res.code == 200){
                    if(this.activeKey == '综合评定'){
                        this.iframeSrc = res.result.wordUrl
                    }else{
                        this.transferLetterIframeSrc = res.result.wordUrl
                    }
                    
                    this.iframeKey = Date.now()
                }else{
                    this.$message.warning(res.message)
                }
            })
        },
        //删除
        producerDelete(val,type){
            var that = this
            this.$confirm({
                title:'您确认要删除吗？',
                // icon: createVNode(ExclamationCircleOutlined),
                onOk() {
                    spcySqsxWjjldeleteFileById({id:val.id}).then(res=>{
                        if(res.code == 200){
                            if(type == '综合评定'){
                                that.getReportData()
                            }else if(type == '移送函报告'){
                                that.getTransferLetter()
                            }
                        }else{
                            that.$message.warning(res.message)
                        }
                    })
                },
                
            });
            
        },
        //上传
        singleUploadCahnge({file},val){
            var that = this
            if(file.name.indexOf('.pdf') !== -1 ){
                const fileData = new FormData();
                fileData.append("file",file);
                fileData.append("sqsxid",this.currentRow.sqsxid);
                fileData.append("type",val);
                spcyuploadSqsxFile(fileData).then(res => {
                    if(res.code !== 200){
                        that.$message.warning('请上传pdf文件或者联系管理员!')
                    }else{
                        that.getMaterialSummary(this.currentRow)
                        that.getFirstMeetingData(this.firstMeetingActiveValue)
                        that.$message.success('上传成功')
                        if(type == '综合评定报告书'){
                            this.getReportData()
                        }else if(type == '移送函'){
                            this.getTransferLetter()
                        }
                    }
                    
                })
            }else{
                this.$message.warning('请上传pdf文件')
            }
            
        },
        refreshFile(){//刷新
            if(this.activeKey == '综合评定'){
                this.getReportData()
            }else{
                this.getTransferLetter()
            }
            
            
        },

        downloadFiles(val){//下载
            var that = this
            let param = { id:val.id,sqsxid:this.currentRow.sqsxid}
            spcySqsxWjjlgetLocalFileById(param).then((data) => {
                if (!data) {
                    that.$message.warning('文件下载失败')
                return
                }
                    let url = window.URL.createObjectURL(new Blob([data], { type: blobType.type[blobType.suffix.indexOf(val.fwjlx)] }))
                    let link = document.createElement('a')
                    link.style.display = 'none'
                    link.href = url
                    link.setAttribute('download', val.fwjxsmc+val.fwjlx)
                    document.body.appendChild(link)
                    link.click()
                    document.body.removeChild(link) //下载完成移除元素
                    window.URL.revokeObjectURL(url) //释放掉blob对象
            })
        },
        
        reEdit(){//重新编辑
            let data = {
                id:this.activeKey == '综合评定'?this.programData.id:this.transferLetterData.id
            }
            againEditPdfOnlineFile(data).then(res=>{
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.refreshFile()
                }else{
                    this.$message.warning(res.message)
                }
            })
        },
        saveFiles(){//保存
            let data = {
                id:this.activeKey == '综合评定'?this.programData.id:this.transferLetterData.id
            }
            getWebOfficeDownloadFile(data).then(res=>{
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.refreshFile()
                }else{
                    this.$message.warning(res.message)
                }
            })
        },
        
        generatePDFClick(){//生成PDF
            let data = {
                id:this.activeKey == '综合评定'?this.programData.id:this.transferLetterData.id
            }
            getDocxToPdf(data).then(res=>{
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.refreshFile()
                }else{
                    this.$message.warning(res.message)
                }
            })
        },
        
        stampClick(){//盖章
            let data = {
                id:this.activeKey == '综合评定'?this.programData.id:this.transferLetterData.id
            }
            pdfFileHcCa(data).then(res=>{
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.refreshFile()
                }else{
                    this.$message.warning(res.message)
                }
            })
        },
        
        generatePDFStampClick(){//生成PDF并盖章
            let data = {
                id:this.activeKey == '综合评定'?this.programData.id:this.transferLetterData.id
            }
            getDocxToPdfAndGz(data).then(res=>{
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.refreshFile()
                }else{
                    this.$message.warning(res.message)
                }
            })
        },
        refreshChange(){
            this.getNoticeMaterial(this.currentRow)
        },
        reSelectTemplate(){//重新选择模板
            //console.log('我点击什么',this.programData)
            this.$refs.selectTemplateRef.getSelectTemplate(this.activeKey == '综合评定'?this.programData:this.transferLetterData,this.activeKey == '综合评定'?'综合评定报告书':'移送函',this.currentRow.sqsxid)
            this.$refs.selectTemplateRef.selectTemplateVisible = true
        },
         //选择模板
        selectTemplateComplete(val){
            if(val == '综合评定报告书'){
                this.getReportData()
            }else{
                this.getTransferLetter()
            }
            
        },
         programSpinningChange(){
            this.programSpinning = true
        },
        rectificationClick(val){
            this.$emit('rectificationClick',val)
        },
        historyListClick(val){
            this.$emit('historyListClick',val)
        },
        //从其他组件更新数据过来
        renewDataChange({name,value}){
            this.currentRow[name] = value
        },
        //保存
        saveData(name,value,obj){
            let data = {
                jobid:this.currentRow.jobid,
                sqsxid:this.currentRow.sqsxid,
                opinion:'',
                smgflag:'否',
                map:{}
            }
            if(name){
                data.map[name] = value
            } else if(obj){
                data.map = {...obj}
            } else{
                data.map = { ...this.currentRow,}
            }
            spcysaveFlow(data).then(res=>{
                if(res.code == 200){
                    this.$message.success(res.message)
                }else{
                    this.$message.warning(res.message)
                }
                this.successChange()
            })
        },
    }
}
</script>
<style lang="less">
//1
.handle-comprehensive-box{
    width: 100%;
    
    // padding: 2px 5px 5px 5px;
    overflow-y: auto;
    // background-color: #fff;
    // .material-review-tabs{
    //     // width: 100%;
    //     padding: 0 5px;
    //     background-color: #fff;
    //     position: relative;
    //     // top: 48px;
    //     top: 0;
    //     right: 0;
    //     // margin:0 10px;
    //     font-size: 20px !important;
    //     font-weight: 600 !important;
    //     .ant-tabs-bar{
    //         margin: 0;
    //     }
    //     .ant-tabs-nav .ant-tabs-tab{
    //         padding-top: 5px;
    //         padding-bottom: 5px;
    //         margin-right: 10px;
    //     }
    //     .ant-tabs-nav-container{
    //         height: 50px !important;
    //     }
    //     .ant-tabs-nav-scroll{
    //         padding-top: 10px;
    //         padding-left: 10px;
    //     }
    // }
    // .ant-tabs-tab-active{
    //     font-size: 16px;
    //     font-weight: 600 !important;
    // }
    // .ant-tabs-tab{
    //     font-size: 16px;
    //     font-weight: 600 !important;
    //     line-height: 28px !important;
    //     border-radius: 10px 10px 0 0 !important;
    // }
    // .ant-tabs-tab-active{
    //     background-color: #5ca3e5 !important;
    //     color: #fff !important;
    //     border-color: #5ca3e5 !important;
    //     box-shadow: 0px 0px 12px 0px #5ca3e5;
    // }
    .comprehensive-review-content{
        // margin: 5px;
        padding: 5px;
        height: calc(100vh - 157px);
        background-color: #fff;
        overflow-y: auto;
        // box-shadow: 0px 0px 12px -3px #69a3d9;
        border:1px solid #38f;
        border-top: 0;
        .file-list-v-examination{
        .file-for-box{
            // display: flex;
            // flex-wrap: wrap;
        }
        .file-for-v-1{
            border-radius: 2px;
            border: 1px solid #d9d9d9;
            border-radius: 15px;
            // display: flex;
            // flex-direction: row;
            // justify-content: space-between;
            // align-items:center;
            padding: 5px;
            margin: 5px 0;
            .file-icon-box{
                margin-right:5px;
                display: flex;
                justify-content: space-evenly;
                .file-icon-v{
                    font-size: 42px;
                    color: rgb(24, 144, 255);
                    padding: 7px;
                }
                // .left-box{
                //     width: 28px;
                // }
                .right-box{
                    display: flex;
                    // flex-direction: column;
                    justify-content: space-evenly;
                    align-items: center;
                    padding-bottom: 2px;
                    width:35px;
                    
                }
                
            }
            .eye-icon-v{
                display:inline-block;
                padding-left: 30px;
                font-size: 18px;
                color: #1ab394;
            }
            .name-fclmc-text{
                // height: 60px;
                // text-align: left;
                // display:inline-block;
                // text-overflow: -o-ellipsis-lastline;
                // overflow: hidden;
                // text-overflow: ellipsis;
                // display: -webkit-box;
                // // display: flex;
                // // flex-direction: column;
                // // justify-content: center;
                // -webkit-line-clamp: 3;
                // line-clamp: 3;
                // -webkit-box-orient: vertical;
                font-size: 14px;
            }
        }
        .directory-list-fmlmc{
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            margin-bottom: 10px;
            font-weight: 600;
        }
        .select-file-list-examination{
            // background-color: #38f;
            // a{
            //     color: #fff;
            // }
            background-image: linear-gradient(to bottom, #e7f3ff, #fff, #e7f3ff, #e7f3ff, #e7f3ff, #e7f3ff, #e7f3ff, #e7f3ff, #e7f3ff);
            background-size: 100% 100% !important;
            border: 2px solid #ff9200;
        }
        
    }
    }
}
//2
.handle-comprehensive-box{
    .review-table{
        th{
            text-align: center;
            padding: 10px;
        }
        td{
            padding: 10px;
        }
    }
    .file-list-v{
        .file-for-box{
            // display: flex;
            // flex-wrap: wrap;
        }
        .file-for-v{
            width: 130px;
            height: 130px;
            border-radius: 2px;
            border: 1px solid #d9d9d9;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            padding: 5px;
            margin: 5px;
            .file-icon-box{
                display: flex;
                justify-content: space-between;
                .file-icon-v{
                    font-size: 42px;
                    color: rgb(24, 144, 255);
                    padding: 7px;
                }
                .left-box{
                    width: 28px;
                }
                .right-box{
                    display: flex;
                    flex-direction: column;
                    justify-content: space-between;
                    padding-bottom: 2px;
                    .eye-icon-v{
                        font-size: 18px;
                        color: rgb(24, 144, 255);
                    }
                }
            }
            
            .name-fclmc-text{
                height: 60px;
                text-align: center;
                display:block;
                text-overflow: -o-ellipsis-lastline;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                // display: flex;
                // flex-direction: column;
                // justify-content: center;
                -webkit-line-clamp: 3;
                line-clamp: 3;
                -webkit-box-orient: vertical;
                font-size: 14px;
            }
        }
        
    }
    .business-number{
        display: flex;
        margin: 6px 0;
        // justify-content: space-between;
        align-items: center;
        .business-number-dg{
            // width: 332px;
            margin-right: 30px;
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            .business-name{
                display: inline-block;
                width: 130px;
                text-align: right;
            }
        }
    }
    .business-name-text{
        text-align: right;
        width: 105px;
    }

    
}
.processing-content-right-v{
    margin-left: 150px;
    background-color: #fff;
}
</style>